clear
use dictator_replication_public.dta, replace

** Table 1 demographics are not linked to the public data due to concerns about maintaining respondent confidentiality. Contact Lance Howe (elhowe@alaska.edu) for more information.

** TABLE 2 -- SUMMARY STATISTICS
** unconditional summary stats
	table dtreat set if dict_pct_earnings ~=., stat() 
	table dtreat set if dict_pct_earnings ~=., stat(mean amount_given) nformat(%9.2f)
	table dtreat set if dict_pct_earnings ~=., stat(sd amount_given)  nformat(%9.2f)
	table dtreat set if dict_pct_earnings ~=., stat(median amount_given) nformat(%9.2f)
	
	table dtreat set if dict_pct_earnings ~=., stat(mean dict_pct_earnings)  nformat(%9.2f)
	table dtreat set if dict_pct_earnings ~=., stat(sd dict_pct_earnings)  nformat(%9.2f)
	table dtreat set if dict_pct_earnings ~=., stat(median dict_pct_earnings)  nformat(%9.2f)
	
** conditional on sharing summary stats
	table dtreat set if dict_pct_earnings ~=. & positive_giving ==1, stat() 
	table dtreat set if dict_pct_earnings ~=. & positive_giving ==1, stat(mean amount_given) nformat(%9.2f)
	table dtreat set if dict_pct_earnings ~=. & positive_giving ==1, stat(sd amount_given)  nformat(%9.2f)
	table dtreat set if dict_pct_earnings ~=. & positive_giving ==1, stat(median amount_given) nformat(%9.2f)
	
	table dtreat set if dict_pct_earnings ~=. & positive_giving ==1, stat(mean dict_pct_earnings)  nformat(%9.2f)
	table dtreat set if dict_pct_earnings ~=. & positive_giving ==1, stat(sd dict_pct_earnings)  nformat(%9.2f)
	table dtreat set if dict_pct_earnings ~=. & positive_giving ==1, stat(median dict_pct_earnings)  nformat(%9.2f)
	
	
** TABLE 3 -- PERCENT OF TOTAL EARNINGS SHARED
estimates clear
gl tests "test1 test2 test3 test4 test5 test6 test7 test8 test9 test10" 

eststo R1: reg dict_pct_earnings  ib1.dtreat if positive_giving ==1 & roundcounts_all == 1 & set == 1, r
	test _b[1.dtreat] = _b[2.dtreat]
	estadd scalar test1=r(p): R1
	test _b[1.dtreat] = _b[3.dtreat]
	estadd scalar test2=r(p): R1
	test _b[1.dtreat] = _b[4.dtreat]
	estadd scalar test3=r(p): R1
	test _b[1.dtreat] = _b[5.dtreat]
	estadd scalar test4=r(p): R1
	test _b[2.dtreat] = _b[3.dtreat]
	estadd scalar test5=r(p): R1
	test _b[2.dtreat] = _b[4.dtreat]
	estadd scalar test6=r(p): R1
	test _b[2.dtreat] = _b[5.dtreat]
	estadd scalar test7=r(p): R1
	test _b[3.dtreat] = _b[4.dtreat]
	estadd scalar test8=r(p): R1
	test _b[3.dtreat] = _b[5.dtreat]
	estadd scalar test9=r(p): R1
	test _b[4.dtreat] = _b[5.dtreat]
	estadd scalar test10=r(p): R1

eststo R2: reg dict_pct_earnings  ib1.dtreat if positive_giving ==1 & roundcounts_all == 1 & set == 2, r
	test _b[1.dtreat] = _b[2.dtreat]
	estadd scalar test1=r(p): R2
	test _b[1.dtreat] = _b[3.dtreat]
	estadd scalar test2=r(p): R2
	test _b[1.dtreat] = _b[4.dtreat]
	estadd scalar test3=r(p): R2
	test _b[1.dtreat] = _b[5.dtreat]
	estadd scalar test4=r(p): R2
	test _b[2.dtreat] = _b[3.dtreat]
	estadd scalar test5=r(p): R2
	test _b[2.dtreat] = _b[4.dtreat]
	estadd scalar test6=r(p): R2
	test _b[2.dtreat] = _b[5.dtreat]
	estadd scalar test7=r(p): R2
	test _b[3.dtreat] = _b[4.dtreat]
	estadd scalar test8=r(p): R2
	test _b[3.dtreat] = _b[5.dtreat]
	estadd scalar test9=r(p): R2
	test _b[4.dtreat] = _b[5.dtreat]
	estadd scalar test10=r(p): R2

eststo R3: reg dict_pct_earnings  ib1.dtreat if dict_pct_earnings<100 & positive_giving ==1 & roundcounts_all == 1 & set == 2, r
	test _b[1.dtreat] = _b[2.dtreat]
	estadd scalar test1=r(p): R3
	test _b[1.dtreat] = _b[3.dtreat]
	estadd scalar test2=r(p): R3
	test _b[1.dtreat] = _b[4.dtreat]
	estadd scalar test3=r(p): R3
	test _b[1.dtreat] = _b[5.dtreat]
	estadd scalar test4=r(p): R3
	test _b[2.dtreat] = _b[3.dtreat]
	estadd scalar test5=r(p): R3
	test _b[2.dtreat] = _b[4.dtreat]
	estadd scalar test6=r(p): R3
	test _b[2.dtreat] = _b[5.dtreat]
	estadd scalar test7=r(p): R3
	test _b[3.dtreat] = _b[4.dtreat]
	estadd scalar test8=r(p): R3
	test _b[3.dtreat] = _b[5.dtreat]
	estadd scalar test9=r(p): R3
	test _b[4.dtreat] = _b[5.dtreat]
	estadd scalar test10=r(p): R3

eststo R4: reg dict_pct_earnings  ib1.dtreat if positive_giving ==1 & roundcounts_all == 1 & set == 3, r
	test _b[1.dtreat] = _b[2.dtreat]
	estadd scalar test1=r(p): R4
	test _b[1.dtreat] = _b[3.dtreat]
	estadd scalar test2=r(p): R4
	test _b[1.dtreat] = _b[4.dtreat]
	estadd scalar test3=r(p): R4
	test _b[1.dtreat] = _b[5.dtreat]
	estadd scalar test4=r(p): R4
	test _b[2.dtreat] = _b[3.dtreat]
	estadd scalar test5=r(p): R4
	test _b[2.dtreat] = _b[4.dtreat]
	estadd scalar test6=r(p): R4
	test _b[2.dtreat] = _b[5.dtreat]
	estadd scalar test7=r(p): R4
	test _b[3.dtreat] = _b[4.dtreat]
	estadd scalar test8=r(p): R4
	test _b[3.dtreat] = _b[5.dtreat]
	estadd scalar test9=r(p): R4
	test _b[4.dtreat] = _b[5.dtreat]
	estadd scalar test10=r(p): R4

eststo R5: reg dict_pct_earnings  ib1.dtreat if dict_pct_earnings<100 & positive_giving ==1 & roundcounts_all == 1 & set == 3, r
	test _b[1.dtreat] = _b[2.dtreat]
	estadd scalar test1=r(p): R5
	test _b[1.dtreat] = _b[3.dtreat]
	estadd scalar test2=r(p): R5
	test _b[1.dtreat] = _b[4.dtreat]
	estadd scalar test3=r(p): R5
	test _b[1.dtreat] = _b[5.dtreat]
	estadd scalar test4=r(p): R5
	test _b[2.dtreat] = _b[3.dtreat]
	estadd scalar test5=r(p): R5
	test _b[2.dtreat] = _b[4.dtreat]
	estadd scalar test6=r(p): R5
	test _b[2.dtreat] = _b[5.dtreat]
	estadd scalar test7=r(p): R5
	test _b[3.dtreat] = _b[4.dtreat]
	estadd scalar test8=r(p): R5
	test _b[3.dtreat] = _b[5.dtreat]
	estadd scalar test9=r(p): R5
	test _b[4.dtreat] = _b[5.dtreat]
	estadd scalar test10=r(p): R5
	
esttab R1 R2 R3 R4 R5 using "Table3.rtf" , label cells(b(star fmt(%9.2f)) se(par fmt(%9.2f))) starlevels(* .10 ** .05 *** .01) ///
	stats(N $tests, fmt(0 3) ///
	labels("N" "T1=T2" "T1=T3" "T1=T4" "T1=T5"  ///
	           "T2=T3" "T2=T4" "T2=T5" ///
	           "T3=T4" "T3=T5" "T4=T5" ///
						  ) )  ///	
	mlabels("W.AK (all)" "Kam. (all)" "Kam. (no outliers)" "UAA(all)" "UAA(no outliers)") collabels(none) ///
	addnotes("Robust standard errors are clustered at the group-level.") ///
	title("Table 3. Percent of Earnings Shared (conditional on sharing)") replace	

**************************

*** TABLE 4. PROBABILITY OF GIVING
estimates clear
eststo R1: reg positive_giving  ib1.dtreat if  roundcounts_all == 1 & dict_pct_earnings ~=. & set == 1, r
	test _b[1.dtreat] = _b[2.dtreat]
	estadd scalar test1=r(p): R1
	test _b[1.dtreat] = _b[3.dtreat]
	estadd scalar test2=r(p): R1
	test _b[1.dtreat] = _b[4.dtreat]
	estadd scalar test3=r(p): R1
	test _b[1.dtreat] = _b[5.dtreat]
	estadd scalar test4=r(p): R1
	test _b[2.dtreat] = _b[3.dtreat]
	estadd scalar test5=r(p): R1
	test _b[2.dtreat] = _b[4.dtreat]
	estadd scalar test6=r(p): R1
	test _b[2.dtreat] = _b[5.dtreat]
	estadd scalar test7=r(p): R1
	test _b[3.dtreat] = _b[4.dtreat]
	estadd scalar test8=r(p): R1
	test _b[3.dtreat] = _b[5.dtreat]
	estadd scalar test9=r(p): R1
	test _b[4.dtreat] = _b[5.dtreat]
	estadd scalar test10=r(p): R1

eststo R2: reg positive_giving ib1.dtreat if roundcounts_all == 1 & dict_pct_earnings ~=. & set == 2, r
	test _b[1.dtreat] = _b[2.dtreat]
	estadd scalar test1=r(p): R2
	test _b[1.dtreat] = _b[3.dtreat]
	estadd scalar test2=r(p): R2
	test _b[1.dtreat] = _b[4.dtreat]
	estadd scalar test3=r(p): R2
	test _b[1.dtreat] = _b[5.dtreat]
	estadd scalar test4=r(p): R2
	test _b[2.dtreat] = _b[3.dtreat]
	estadd scalar test5=r(p): R2
	test _b[2.dtreat] = _b[4.dtreat]
	estadd scalar test6=r(p): R2
	test _b[2.dtreat] = _b[5.dtreat]
	estadd scalar test7=r(p): R2
	test _b[3.dtreat] = _b[4.dtreat]
	estadd scalar test8=r(p): R2
	test _b[3.dtreat] = _b[5.dtreat]
	estadd scalar test9=r(p): R2
	test _b[4.dtreat] = _b[5.dtreat]
	estadd scalar test10=r(p): R2

eststo R3: reg positive_giving  ib1.dtreat if roundcounts_all == 1 & dict_pct_earnings ~=. & set == 3, r
	test _b[1.dtreat] = _b[2.dtreat]
	estadd scalar test1=r(p): R3
	test _b[1.dtreat] = _b[3.dtreat]
	estadd scalar test2=r(p): R3
	test _b[1.dtreat] = _b[4.dtreat]
	estadd scalar test3=r(p): R3
	test _b[1.dtreat] = _b[5.dtreat]
	estadd scalar test4=r(p): R3
	test _b[2.dtreat] = _b[3.dtreat]
	estadd scalar test5=r(p): R3
	test _b[2.dtreat] = _b[4.dtreat]
	estadd scalar test6=r(p): R3
	test _b[2.dtreat] = _b[5.dtreat]
	estadd scalar test7=r(p): R3
	test _b[3.dtreat] = _b[4.dtreat]
	estadd scalar test8=r(p): R3
	test _b[3.dtreat] = _b[5.dtreat]
	estadd scalar test9=r(p): R3
	test _b[4.dtreat] = _b[5.dtreat]
	estadd scalar test10=r(p): R3

	
esttab R1 R2 R3 using "Table4.rtf" , label cells(b(star fmt(%9.2f)) se(par fmt(%9.2f))) starlevels(* .10 ** .05 *** .01) ///
	stats(N $tests, fmt(0 3) ///
	labels("N" "T1=T2" "T1=T3" "T1=T4" "T1=T5"  ///
	           "T2=T3" "T2=T4" "T2=T5" ///
	           "T3=T4" "T3=T5" "T4=T5" ///
						  ) )  ///	
	mlabels("W.AK" "Kam." "UAA") collabels(none) ///
	addnotes("Robust standard errors are clustered at the group-level.") ///
	title("Table 4. Positive Amount Shared (linear probability model)") replace	
	
	
****************
estimates clear

*** confidence interval plots **
*ciplot uses the ci routine in stata - help ci


* FIGURE 1 - Percent of Experiment Earnings Shared
* Percent of Experiment Earnings Shared - Conditional on Sharing
ciplot dict_pct_earnings if positive_giving>0 & set==1  & roundcounts_all == 1, by(dtreat) ytitle("Percent") ylabel(0(10)100, angle(horizontal) labsize(small)) xtitle(Treatment)  xlabel(, labsize(small) valuelabel ) title("Percent of Earnings Shared - Conditional on Sharing") subtitle("Western Alaska") name(c_pctearnshared_wak, replace)

ciplot dict_pct_earnings if positive_giving>0 & set==2 & roundcounts_all == 1, by(dtreat) ytitle("Percent") ylabel(0(10)100, angle(horizontal) labsize(small)) xtitle(Treatment)  xlabel(, labsize(small) valuelabel ) title("Percent of Earnings Shared - Conditional on Sharing") subtitle("Kamchatka") name(c_pctearnshared_kam, replace)

ciplot dict_pct_earnings if positive_giving>0 & set==3 & roundcounts_all == 1, by(dtreat) ytitle("Percent") ylabel(0(10)100, angle(horizontal) labsize(small)) xtitle(Treatment)  xlabel(, labsize(small) valuelabel ) title("Percent of Earnings Shared - Conditional on Sharing") subtitle("UAA") name(c_pctearnshared_uaa, replace)

* Percent of Experiment Earnings Shared (unconditional)
ciplot dict_pct_earnings if set==1  & roundcounts_all == 1, by(dtreat) ytitle("Percent of Earnings") ylabel(0(5)25, angle(horizontal) labsize(small)) xtitle(Treatment)  xlabel(, labsize(small) valuelabel ) title("Percent of Earnings Shared") subtitle("Western Alaska") name(pctearnshared_wak, replace)

ciplot dict_pct_earnings if set==2 & roundcounts_all == 1, by(dtreat) ytitle("Percent of Earnings") ylabel(0(5)25, angle(horizontal) labsize(small)) xtitle(Treatment)  xlabel(, labsize(small) valuelabel ) title("Percent of Earnings Shared") subtitle("Kamchatka") name(pctearnshared_kam, replace)

ciplot dict_pct_earnings if set==3 & roundcounts_all == 1, by(dtreat) ytitle("Percent of Earnings") ylabel(0(5)25, angle(horizontal) labsize(small)) xtitle(Treatment)  xlabel(, labsize(small) valuelabel ) title("Percent of Earnings Shared") subtitle("UAA") name(pctearnshared_uaa, replace)


* FIGURE 2 - Percent of Subjects with Positive Amount Shared
*convert to percent, not percentage
gen positive_giving_pct = positive_giving*100

ciplot positive_giving_pct if set==1 & roundcounts_all == 1, by(dtreat) ytitle("Percent of Subjects") ylabel(0(10)100, angle(horizontal) labsize(small)) xtitle(Treatment)  xlabel(, labsize(small) valuelabel ) title("Positive Amount Shared") subtitle("Western Alaska") name(pos_sharing_wak, replace)

ciplot positive_giving_pct if set==2 & roundcounts_all == 1, by(dtreat) ytitle("Percent of Subjects") ylabel(0(10)100, angle(horizontal) labsize(small)) xtitle(Treatment)  xlabel(, labsize(small) valuelabel ) title("Positive Amount Shared") subtitle("Kamchatka") name(pos_sharing_kam, replace)

ciplot positive_giving_pct if set==3 & roundcounts_all == 1, by(dtreat) ytitle("Percent of Subjects") ylabel(0(10)100, angle(horizontal) labsize(small)) xtitle(Treatment)  xlabel(, labsize(small) valuelabel ) title("Positive Amount Shared") subtitle("UAA") name(pos_sharing_uaa, replace)



		